package cn.qyd.singlemodel;

import java.util.ArrayList;

/**
 * @author 邱运铎
 * @date 2024-03-14 21:38
 */
public class InteriorStaticClassDemo {

    private InteriorStaticClassDemo() {};

    private static class InteriorStaticClassDemoHelper {
        public final static InteriorStaticClassDemo instance = new InteriorStaticClassDemo();
    }

    public static InteriorStaticClassDemo getInstance() {
        return InteriorStaticClassDemoHelper.instance;
    }

    public static void main(String[] args) {
        ArrayList<InteriorStaticClassDemo> demos = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                demos.add(InteriorStaticClassDemo.getInstance());
            }).start();
        }

        while (Thread.activeCount() > 2) {
            Thread.yield();
        }

        demos.forEach(System.out::println);
    }
}
